package marmalius;
/*
	gestion des emotes des npcs
	modifie par Metos [EOAH]
*/

import java.sql.*;

import marmalius.tools.DBService;
import marmalius.tools.LogService;

public class NpcAnimHandler {
	public static int maxEmote = 3800;
	
	public int [] block = new int[maxEmote];
	public int [] atk = new int[maxEmote];
	public int [] die = new int[maxEmote];
	
	public NpcAnimHandler () {
		for (int i = 0; i < maxEmote; i++) {
			block[i] = 0;
			atk[i] = 0;
			die[i] = 0;
		}
		loadEmote();
	}
	
	public void addEmote(int npcid, int natk, int nblk, int ndie) {
		atk[npcid] = natk;
		block[npcid] = nblk;
		die[npcid] = ndie;
	}

	private void loadEmote () {
		try {
			int nb = 0;
			ResultSet rs = DBService.getInstance().doQuery("SELECT * FROM npc_emotes");
			while (rs.next()) {
				addEmote(rs.getInt("npcid"), rs.getInt("atk"), rs.getInt("blk"), rs.getInt("die"));
				nb++;
			}
			LogService.getInstance().logInfo("npc_emotes load ("+nb+")");
		}
		catch (SQLException ex) {
			LogService.getInstance().logError("Can't load npc_emotes");
			LogService.getInstance().logError(ex.getMessage());
		}
	}
}